#ifndef __ALIIOTCONTROL_H__
#define __ALIIOTCONTROL_H__

#include <WiFiClient.h>
#include <ArduinoJson.h>
#include "FishControl.h"
#include "AliyunIoTSDK.h"

class AliIoTControl
{
private:
    WiFiClient aliClient;

    bool ready;
public:
    AliIoTControl();
    ~AliIoTControl();

    void begin();
    void loop();

    template<typename T>
    bool send(char *key, T value);

    void updateStatus();

private:
    void powerOnChange(JsonVariant ele);
    void lampTypeOnChange(JsonVariant ele);
    void brightnesspeOnChange(JsonVariant ele);
};


template<typename T>
bool AliIoTControl::send(char *key, T value)
{
    if (!ready) return false;
    AliyunIoTSDK::send(key, value);
    return true;
}

extern AliIoTControl aliIotControl;
#endif // __ALIIOTCONTROL_H__